//
//  ViewController.m
//  UI06_UIScrollView
//
//  Created by Scott on 16/5/10.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "PictureScrollView.h"

@interface ViewController () <UIScrollViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self createScrollView];
    
}

#pragma mark - 知识点1: UIScorllView
- (void)createScrollView {
    
    PictureScrollView *scroll = [[PictureScrollView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)];
    
    scroll.center = self.view.center;
    [self.view addSubview:scroll];
    [scroll release];
    
    scroll.backgroundColor = [UIColor greenColor];
    
    UIImage *image1 = [UIImage imageNamed:@"1.jpg"];
    UIImage *image2 = [UIImage imageNamed:@"2.jpg"];
    UIImage *image3 = [UIImage imageNamed:@"3.jpg"];
    
    [scroll addPictures:@[image1, image2, image3]];
    
    scroll.delegate = self;
    
}

#pragma mark - 知识点2: UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

//    NSLog(@"%s", __FUNCTION__);
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {

//    NSLog(@"%s", __FUNCTION__);
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

//    NSLog(@"%s", __FUNCTION__);
    
    
    NSLog(@"%@", NSStringFromCGPoint(scrollView.contentOffset));
    
}

#pragma mark ** 缩放
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {

    return [scrollView.subviews firstObject];

}





@end
